package spring.cloud.eurekaclientproduct.cmd;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import spring.cloud.eurekaclientproduct.service.UserFacade;
import com.spring.cloud.commonutils.vo.UserInfo;

import java.util.List;

public class UserFindCommand extends HystrixCommand<List<UserInfo>> {

    private Long[] ids = null;
    private UserFacade userFacade;

    public UserFindCommand(UserFacade userFacade,Long[] ids) {
        super(HystrixCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("userGroup")));
        this.ids = ids;
        this.userFacade = userFacade;
    }

    @SuppressWarnings("unchecked")
    @Override
    protected List<UserInfo> run() throws Exception {
        List<UserInfo> users = userFacade.findUsers(ids);
        return users;
    }
}
